<?php
namespace App\Http\Controllers\ApiQd;

use App\Service\ApiQd\CommonService;
use Illuminate\Http\Request;

class CommonController extends BaseController
{
    //配置

    public function __construct()
    {
        $this->db = new CommonService();
    }

    //所有配置列表
    public function getAllConfig(Request $request)
    {
        $res = $this->db->getAllConfig();
//        $res = $this->config();
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data']);
    }

    //单个配置
    public function getConfigByKey(Request $request)
    {
        $key = $request->post('key', '');
        $res = $this->db->getConfigByKey($key);
//        $res = $this->config($key);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data']);
    }
}